package com.woniuxy.controller;

import com.woniuxy.entity.DataClass;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @author 佘赛飞
 * @create 2021-11-24 4:38 下午
 */
@Controller
public class MySpringBootController {
    @RequestMapping("/index")
    public String index() {
        return "index";
    }

    //普通日前转换方式
    @RequestMapping("/testDate")
    @ResponseBody
    public String testDate(@RequestParam Date times) {
        return times.toString();
    }

    //使用对象+Json日期转换
    @RequestMapping("/testjsonDate")
    @ResponseBody
    public String testjsonDate(@RequestBody DataClass dataClass) {
        return dataClass.getTimes().toString();
    }
}
